<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="${#request.getContextPath() + '/system/'}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
    <!-- Reset Stylesheet -->
    <link rel="stylesheet" href="resources/css/reset.css" type="text/css"
          media="screen" />
    <!-- Main Stylesheet -->
    <link rel="stylesheet" href="resources/css/style.css" type="text/css"
          media="screen" />
    <link rel="stylesheet" href="resources/css/invalid.css" type="text/css"
          media="screen" />

    <!--                       Javascripts                       -->
    <!-- jQuery -->
    <script type="text/javascript"
            src="resources/scripts/jquery-1.8.3.min.js"></script>
    <!-- jQuery Configuration -->
    <script type="text/javascript"
            src="resources/scripts/simpla.jquery.configuration.js"></script>

    <!-- 日期插件 -->
    <link rel="stylesheet"
          th:href="${#request.getContextPath() + '/system/resources/widget/My97DatePicker/skin/WdatePicker.css'}"
          type="text/css"/>
    <script type="text/javascript"
            th:src="${#request.getContextPath() + '/system/resources/widget/My97DatePicker/WdatePicker.js'}"></script>


</head>
<body>
<div id="main-content">
    <div class="content-box">
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <h2>系统日志</h2>
            <!-- 搜索 -->
            <form th:action="${#request.getContextPath() + '/log/syssearch'}" method="post">
                日志类型：
                <select name="typeVal">
                    <option value="0" th:selected="${searchLog != null && searchLog.typeVal == 0}">所有类型</option>
                    <option value="1" th:selected="${searchLog != null && searchLog.typeVal == 1}">登录</option>
                    <option value="2" th:selected="${searchLog != null && searchLog.typeVal == 2}">注销</option>
                    <option value="3" th:selected="${searchLog != null && searchLog.typeVal == 3}">添加</option>
                    <option value="4" th:selected="${searchLog != null && searchLog.typeVal == 4}">修改</option>
                    <option value="5" th:selected="${searchLog != null && searchLog.typeVal == 5}">删除</option>
                </select>
                &nbsp;&nbsp;&nbsp;&nbsp;
                操作时间：
                <input class="text-input" autocomplete="off" name="mintime" th:value="${searchLog != null ? searchLog.minStr : ''}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"/>
                -
                <input class="text-input" autocomplete="off" name="maxtime" th:value="${searchLog != null ? searchLog.maxStr : ''}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"/>
                <button type="submit" class="mybutton">搜索</button>
            </form>

            <br/>
            <hr/>
            <br/>

            <div class="tab-content default-tab" id="tab1">
                <form id="formid" action="" method="post">
                <table>
                    <thead>
                    <tr>
                        <th><input class="check-all" type="checkbox"/>全选</th>
                        <th>操作类型</th>
                        <th>操作人</th>
                        <th>操作时间</th>
                        <th>备注</th>
                        <th>结果</th>
                        <th>异常</th>
                    </tr>
                    </thead>

                    <tbody>
                    <tr th:each="syslog : ${systemLogList}">
                        <td><input type="checkbox" name="logid" th:value="${syslog.id}"/></td>
                        <td th:switch="${syslog.type}">
                            <span th:case="1">登录</span>
                            <span th:case="2">注销</span>
                            <span th:case="3">增加</span>
                            <span th:case="4">修改</span>
                            <span th:case="5">删除</span>
                        </td>
                        <td th:text="${syslog.user}">Lorem ipsum dolor</td>
                        <td th:text="${#dates.format(syslog.time, 'yyyy-MM-dd HH:mm:ss')}"><a href="#" title="title">Sit amet</a></td>
                        <td th:text="${syslog.info}">Consectetur adipiscing</td>
                        <td th:utext="${syslog.flag == 1 ? '<font color=green>成功</font>' : '<font color=red>失败</font>'}">Donec tortor diam</td>
                        <td th:text="${syslog.exception != null ? syslog.exception : '无'}">Consectetur adipiscing</td>
                        <!--<td>
                            &lt;!&ndash; Icons &ndash;&gt; <a href="#" title="Edit"><img
                                src="resources/images/icons/pencil.png" alt="Edit" /></a> <a
                                href="#" title="Delete"><img
                                src="resources/images/icons/cross.png" alt="Delete" /></a> <a
                                href="#" title="Edit Meta"><img
                                src="resources/images/icons/hammer_screwdriver.png"
                                alt="Edit Meta" /></a>
                        </td>-->
                    </tr>
                    </tbody>

                    <!-- 脚部 -->
                    <tfoot>
                    <tr>
                        <td colspan="7">
                            <div class="bulk-actions align-left">
                                <a class="mybutton" href="javascript:deleteLog(1);">删除日志</a>
                            </div>
                            <div class="bulk-actions align-left" style="margin-left: 10px">
                                <a class="mybutton" href="javascript:deleteLog(0);">清空所有日志</a>
                            </div>
                            <!-- 分页导航 -->
                            <div class="pagination" th:replace="system/page :: fenye">
                            </div> <!-- End .pagination -->
                            <div class="clear"></div>
                        </td>
                    </tr>
                    </tfoot>
                </table>
                </form>

                <script th:inline="javascript">
                    /**
                     * 删除指定日志
                     */
                    function deleteLog(flag){

                        var text = "确定要清空所有的日志信息吗？";
                        if(flag == 1){
                            //批量删除
                            var length = $("input[type='checkbox'][name='logid']:checked").length;
                            if(length <= 0){
                                alert("请至少选择一条日志记录");
                                return;
                            }

                            text = "确定要删除指定的日志信息吗？";
                        }

                        if(confirm(text)){
                            var out_trade_no = [[${#request.getContextPath()}]];
                            $("#formid").attr("action", out_trade_no + "/log/deleteLog?clear=" + flag);
                            //提交表单
                            $("#formid").submit();
                        }
                    }

                </script>
            </div>
        </div>
        <!-- End .content-box-content -->
    </div>
</div>
<!-- End #main-content -->
</body>
</html>